package com.CST.common.api;

import io.swagger.annotations.*;
import lombok.*;

/**
 * @description:页面对象
 * @author: wzw
 * @time: 2019/11/6 14:13
 */
@Data
@ApiModel
public class ResultPageObject {

    @ApiModelProperty(value = "状态码")
    private Integer code;
    @ApiModelProperty(value = "每页条数")
    private Integer pageSize;
    @ApiModelProperty(value = "总条数")
    private Long total;
    @ApiModelProperty(value = "数据")
    private Object data;
    @ApiModelProperty(value = "当前页")
    private Integer pageCurrent;
    @ApiModelProperty(value = "总页数")
    private Long totalPages;

    private String errMsg;

    public ResultPageObject() {
    }

    public ResultPageObject(Integer code, Integer pageSize, Long total, Object data,
				    Integer pageCurrent, Long totalPages) {
	  this.code = code;
	  this.pageSize = pageSize;
	  this.total = total;
	  this.data = data;
	  this.pageCurrent = pageCurrent;
	  this.totalPages = totalPages;

    }

    public ResultPageObject(Integer code, String errMsg) {
	  this.code = code;
	  this.errMsg = errMsg;
    }

    public static ResultPageObject successReturn(Integer pageSize, Long total, Object data,
								 Integer pageCurrent, Long totalPages) {
	  return new ResultPageObject(200, pageSize, total, data, pageCurrent, totalPages);
    }

    /**
     * @param message 错误信息
     * @Description://
     * @Param:
     * @Return:
     * @Author: wzw
     * @Date: 2019/11/25 18:04
     */
    public static ResultPageObject errorPageObject(String message) {
	  return new ResultPageObject(500, message);
    }

}
